﻿@model IPagedList<Classified.Domain.Entities.User>

@using MvcPaging

@{
    ViewBag.Title = "List";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}


<h1>List <small>of Users</small></h1>

<p class="noprint">
     <a href="@Url.Action("Create", "User")" class="btn btn-info" ><i class="icon-user icon-white"></i>  Create New</a>
   </p>

<table class="table table-bordered table-striped">
    <thead>
        @*<th>
            Name 
        </th>*@
       
        <th>
            User Name
        </th>
        <th>
            Email
        </th>
       
        <th>
            Role
        </th>
        <th class="noprint" width="15%"></th>
    </thead>

    @foreach (var item in Model) {
        var i = 0;
        <tr>
            @* <td>
            @Html.DisplayFor(modelItem => item.FirstName)&nbsp; @Html.DisplayFor(modelItem => item.LastName)
        </td>*@
      
            <td>
                @Html.DisplayFor(modelItem => item.UserName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Email)
            </td>
       
            <td>
            
                @foreach(var role in item.Roles)
                {
                    if(i>0)
                    {
                        <text>,&nbsp;</text>
                    }
                    <text>
                        @role.RoleName
                    </text>
                    i++;
                }
            </td>
            <td>
                <a href="@Url.Action("Edit", "User", new { id = item.Id })" class="btn btn-primary" ><i class=" icon-edit icon-white"></i> Edit</a>
                <a href="@Url.Action("Delete","User",new{id=item.Id})" class="btn btn-danger" onclick="return confirm('Are you sure you wish to delete this user and its all records?');"><i class="icon-trash icon-white"></i> Delete</a>
            </td>
        </tr>
    }

</table>

<div class="pagingContainer">
    @Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)
</div>
